package edu.sctu.zhoudie.mouth201506.day20150609;

import java.util.List;

/**
 * Created by user08 on 2015/6/9.
 */
public class DtailUtil {
    private String weijin = "管制刀具";
    private SetTrianData settriandata;
    private SetPeopleData peole;

    /**
     * 构造函数
     *
     */
    public DtailUtil() {
        settriandata = new SetTrianData();
        peole = new SetPeopleData();
    }

    /**
     * 获取乘客
     *
     */
    public void getPeople() {
        List<PeopleAppbean> list = peole.setPeopleData();
        for (PeopleAppbean people : list) {
            if (people.isIs_card()) {
                String problem = chaBaoGuo(people);
                System.out.println(problem);
                if (problem.contains("无")) {
                    kouPrice(people);
                }
            } else {

            }
        }
    }

    /**
     * 判断包裹
     *
     * @param people
     * @return
     */
    public String chaBaoGuo(PeopleAppbean people) {
        PackegeDeth packegeDeth = new PackegeDeth(people, weijin);
        if (packegeDeth.chaBaoGuo()) {
            return "包裹有问题";
        } else {
            return chaWater(people);
        }
    }

    /**
     * 判断水是否有问题
     *
     * @param people
     * @return
     */
    public String chaWater(PeopleAppbean people) {
        PackegeDeth packegeDeth = new PackegeDeth(people, weijin);
        if (packegeDeth.chaWater()) {
            return "水有问题";
        } else {
            ifPrice(people);
            return "都无问题";
        }
    }

    /**
     * 判断金额
     *
     * @param people
     */
    public void ifPrice(PeopleAppbean people) {
        if (people.getPrice() > 2) {
            System.out.println("进站");
        } else {
            new CardDeth().setPrice(10, people);
            System.out.println("充值完成");
            ifPrice(people);
        }

    }

    public void kouPrice(PeopleAppbean people) {
        CardDeth cardeth = new CardDeth(settriandata.setHashMapData());
        if (people.getPrice() >= cardeth.getPrice(people.getStart(),
                people.getEnd())) {
            System.out.println("出站,余额为:"
                    + (people.getPrice() - cardeth.getPrice(people.getStart(),
                    people.getEnd())));
        } else {
            cardeth.setPrice(10, people);
            System.out.println("充值成功");
            kouPrice(people);
        }
    }
}
